package org.blog.model;

import org.blog.util.StringHelper;

public class ModelComment extends BaseModel implements ValidateModel{
//	private Integer id;//8
//	private String username;//20
	private String content;//200
	private Integer artideId;//8
	private Long createTime;//13
	private Long actionTime;//13
	private Integer action;//状态 1：添加，2：修改，3：删除

//	public Integer getId() {
//		return id;
//	}
//
//	public void setId(Integer id) {
//		this.id = id;
//	}

//	public String getUsername() {
//		return username;
//	}
//
//	public void setUsername(String username) {
//		this.username = username;
//	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getArtideId() {
		return artideId;
	}

	public void setArtideId(Integer artideId) {
		this.artideId = artideId;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Long getActionTime() {
		return actionTime;
	}

	public void setActionTime(Long actionTime) {
		this.actionTime = actionTime;
	}

	public Integer getAction() {
		return action;
	}

	public void setAction(Integer action) {
		this.action = action;
	}

	@Override
	public boolean validate(ActionType type) {
		if (ActionType.ADD.equals(type)) {
			if (StringHelper.isEmptyTrim(getContent()) || null == getArtideId()) {
				return false;
			}
		} else if (ActionType.MODIFY.equals(type)) {
			if (StringHelper.isEmptyTrim(getContent()) || null == getArtideId()
					|| null == getId()) {
				return false;
			}
		} else if (ActionType.DELETE.equals(type)) {
			if (null == getId()) {
				return false;
			}
		} else if (ActionType.GET.equals(type)) {
			if (null == getId()) {
				return false;
			}
		} else if (ActionType.GET_PARENT.equals(type)) {
			if (null == getArtideId()) {
				return false;
			}
		}
		
		return true;
	}

}
